﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace _01_获取当前应用程序目录的函数
{
    internal class Program
    {
        static void Main(string[] args)
        {
            var location = Assembly.GetEntryAssembly().Location;
            Console.WriteLine($"Location: {location}");

            var localSettings = Path.Combine(Path.GetDirectoryName(location), "Settings");
            if (Directory.Exists(localSettings))
            {
                Console.WriteLine($"目录已经存在,目录为: {localSettings}");
            }
            else
            {
                Console.WriteLine($"目录不存在,获取当前用户的应用程序目录");
                var appDataPath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
                var newLocalSettginsDir = Path.Combine(appDataPath, nameof(Program));
                // C:\Users\Fioman\AppData\Roaming\Program
                Console.WriteLine($"Settings不存在的时候创建的新目录为: {newLocalSettginsDir}");
            }

            Console.ReadKey();
        }
    }
}
